//
//  PandaTabbarController.swift
//  SwiftPanda
//
//  Created by 余意 on 2017/2/28.
//  Copyright © 2017年 余意. All rights reserved.
//

import UIKit

class PandaTabbarController: UITabBarController {
    
    let titleArray = ["首页","产品","分享","我的"]
    let nomalImageArray = ["tab_home_b","tab_wealth_b","tab_share_b","tab_mine_b"]
    let selectedImageArray = ["tab_home_a","tab_wealth_a","tab_share_a","tab_mine_a"]
    let vcArray = [HomeViewController(),ProductViewController(),ShareViewController(),MineViewController()]
    
    override func viewDidLoad() {
        super.viewDidLoad()

        for i in [0,1,2,3]
        {
            addVC(vc: vcArray[i], title: titleArray[i], nomalImage: nomalImageArray[i], selectedImage: selectedImageArray[i])
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    private func addVC(vc:UIViewController, title: String, nomalImage: String, selectedImage: String)
    {
        vc.title = title
        vc.tabBarItem.image = UIImage(named:nomalImage)
        
        var selectedMe = UIImage(named:selectedImage)
        selectedMe = selectedMe!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        vc.tabBarItem.selectedImage = selectedMe
        self.tabBar.tintColor = UIColor.orange
        
        let nav = PandaNavigationController(rootViewController:vc)
        nav.navigationBar.barTintColor = UIColor.orange
        
        let navgationDic = [NSForegroundColorAttributeName : UIColor.white]
        nav.navigationBar.titleTextAttributes = navgationDic
        addChildViewController(nav)
    }


}
